package com.lin.gameserver.protobuf;

/**
 * 错误码常量，对应proto中定义的ErrorCode枚举
 */
public class ErrorCode {
    // 成功
    public static final int ERROR_NONE = 0;
    
    // 系统级错误 (1-999)
    public static final int ERROR_SYSTEM_UNKNOWN = 1;
    public static final int ERROR_SYSTEM_TIMEOUT = 2;
    public static final int ERROR_SYSTEM_BUSY = 3;
    public static final int ERROR_SYSTEM_MAINTAIN = 4;
    
    // 通用业务错误 (1000-1999)
    public static final int ERROR_CONFIG = 1001;
    public static final int ERROR_PARAM = 1002;
    public static final int ERROR_PROTOCOL = 1003;
    public static final int ERROR_PERMISSION = 1004;
    public static final int ERROR_OPERATION = 1005;
    public static final int ERROR_TIMEOUT = 1006;
    public static final int ERROR_FREQUENCY = 1007;
    
    // 登录模块错误 (2000-2999)
    public static final int ERROR_LOGIN_TOKEN_INVALID = 2001;
    public static final int ERROR_LOGIN_ACCOUNT_BANNED = 2002;
    public static final int ERROR_LOGIN_SERVER_FULL = 2003;
    public static final int ERROR_LOGIN_VERSION = 2004;
    
    // 大厅模块错误 (3000-3999)
    public static final int ERROR_HALL_NOT_LOGIN = 3001;
    public static final int ERROR_HALL_ROOM_NOT_EXIST = 3002;
    public static final int ERROR_HALL_ROOM_FULL = 3003;
    public static final int ERROR_HALL_ROOM_STARTED = 3004;
    
    // 游戏模块错误 (4000-4999)
    public static final int ERROR_GAME_NOT_STARTED = 4001;
    public static final int ERROR_GAME_ALREADY_STARTED = 4002;
    public static final int ERROR_GAME_NOT_YOUR_TURN = 4003;
    public static final int ERROR_GAME_INVALID_OPERATION = 4004;
    
    // 新增错误码
    public static final int ERROR_HALL_ALREADY_LOGIN = 3005;
    public static final int ERROR_TOKEN_TIMEOUT = 2005;
    public static final int ERROR_PLAYER_NOT_EXIST = 3006;
    public static final int ERROR_VERSION_NOT_MATCH = 2006;
    public static final int ERROR_DATA_NOT_EXIST = 5001;
    public static final int ERROR_DATA_ALREADY_EXIST = 5002;
    public static final int ERROR_DATA_DUPLICATE = 5003;
    public static final int ERROR_HALL_SESSION_INVALID = 3007;
    public static final int ERROR_DATA_NOT_ENOUGH = 5004;
    public static final int ERROR_DATA_MAX = 5005;
    public static final int ERROR_DATA_MIN = 5006;
    public static final int ERROR_CONDITION_NOT_MET = 5007;
    public static final int ERROR_DATABASE = 5008;
    public static final int ERROR_TIME_NOT_ARRIVED = 5009;
    public static final int ERROR_TIME_PASSED = 5010;
    public static final int ERROR_DATA_LOCKED = 5011;
    public static final int ERROR_DATA_TIMEOUT = 5012;
    public static final int ERROR_DATA_INVALID = 5013;
    public static final int ERROR_OPERATION_CANCELED = 5014;
    public static final int ERROR_OPERATION_TIMEOUT = 5015;
    public static final int ERROR_OPERATION_TOO_FREQUENT = 5016;
    public static final int ERROR_SERVICE_NOT_AVAILABLE = 5017;
    
    /**
     * 获取错误码描述
     *
     * @param errorCode 错误码
     * @return 错误描述
     */
    public static String getErrorMessage(int errorCode) {
        switch (errorCode) {
            case ERROR_NONE:
                return "成功";
            case ERROR_SYSTEM_UNKNOWN:
                return "未知系统错误";
            case ERROR_SYSTEM_TIMEOUT:
                return "系统超时";
            case ERROR_SYSTEM_BUSY:
                return "系统繁忙";
            case ERROR_SYSTEM_MAINTAIN:
                return "系统维护中";
            case ERROR_CONFIG:
                return "配置错误";
            case ERROR_PARAM:
                return "参数错误";
            case ERROR_PROTOCOL:
                return "协议错误";
            case ERROR_PERMISSION:
                return "权限不足";
            case ERROR_OPERATION:
                return "操作失败";
            case ERROR_TIMEOUT:
                return "操作超时";
            case ERROR_FREQUENCY:
                return "操作频率过高";
            case ERROR_LOGIN_TOKEN_INVALID:
                return "登录令牌无效";
            case ERROR_LOGIN_ACCOUNT_BANNED:
                return "账号被封禁";
            case ERROR_LOGIN_SERVER_FULL:
                return "服务器已满";
            case ERROR_LOGIN_VERSION:
                return "客户端版本不匹配";
            case ERROR_HALL_NOT_LOGIN:
                return "未登录";
            case ERROR_HALL_ALREADY_LOGIN:
                return "已登录";
            case ERROR_TOKEN_TIMEOUT:
                return "token过期";
            case ERROR_PLAYER_NOT_EXIST:
                return "玩家不存在";
            case ERROR_VERSION_NOT_MATCH:
                return "版本不匹配";
            case ERROR_DATA_NOT_EXIST:
                return "数据不存在";
            case ERROR_DATA_ALREADY_EXIST:
                return "数据已存在";
            case ERROR_DATA_DUPLICATE:
                return "数据重复";
            case ERROR_HALL_SESSION_INVALID:
                return "会话无效";
            default:
                return "未知错误: " + errorCode;
        }
    }
} 